﻿namespace Chaliy.Syndication.UnitTests.MediaRss
{
    using Xunit;
    using XunitExt;
    using Chaliy.Syndication.MediaRss;
    using System;

    public class When_Write_Media_Rating
    {
        [Fact]
        public void Serializer_Should_Write_Rating_Element()
        {
            MediaRating raiting = new MediaRating();

            raiting
                .ShouldMatchMedia("/media:rating", "Rating element SHOULD exists");
        }

        [Fact]
        public void Serializer_Should_Write_Scheme()
        {
            const string etalonScheme = "urn:mpaa";

            MediaRating raiting
                = new MediaRating
                {
                    Scheme = etalonScheme
                };

            raiting
                .ShouldMatchMedia("/media:rating/@scheme", "Scheme attribute SHOULD exists")
                .Value.ShouldEqual(etalonScheme);
        }

        [Fact]
        public void Serializer_Should_Not_Write_Simple_Scheme()
        {
            const string simpleScheme = "urn:simple";

            MediaRating raiting
                = new MediaRating
                {
                    Scheme = simpleScheme
                };

            raiting
                .ShouldNotMatchMedia("/media:rating/@scheme", "Scheme attribute SHOULD NOT exists");
        }

        [Fact]
        public void Serializer_Should_Not_Write_Empty_Scheme()
        {
            const string emptyScheme = "";

            MediaRating raiting
                = new MediaRating
                {
                    Scheme = emptyScheme
                };

            raiting
                .ShouldNotMatchMedia("/media:rating/@scheme", "Scheme attribute SHOULD NOT exists");
        }

        [Fact]
        public void Serializer_Should_Write_Rating_Value()
        {
            const string etaloneValue = "adult";

            MediaRating raiting
                = new MediaRating
                {
                    Value = etaloneValue
                };

            raiting
                .ShouldMatchMedia("/media:rating", "Rating element SHOULD exists")
                .Value.ShouldEqual(etaloneValue);
        }
    }
}
